<?php 
class FrontEndController extends BaseController
{
    // лейаут
    public $layout = 'application';
    //profile
    public $menu = array();
    
    // крошки
    public $breadcrumbs = array();

    // META-теги
    public $table;
    public $metaurl;
    public $metatitle;
    public $metakey;
    public $metadesc;

    public function setMeta($data, $table)
    {
        $metatitle  = isset($data->ln->metatitle)	? $data->ln->metatitle  : $data->metatitle;
        $metakey    = isset($data->ln->metakey)		? $data->ln->metakey    : $data->metakey;
        $metadesc   = isset($data->ln->metadesc)	? $data->ln->metadesc   : $data->metadesc;

        $this->table 	=	$table; 
        $this->metaurl  =   isset($data->alias)	? $data->alias  : '';
        $this->metatitle=   isset($metatitle)  	? $metatitle    : '';
        $this->metakey  =   isset($metakey)    	? $metakey      : '';
        $this->metadesc =   isset($metadesc)   	? $metadesc     : '';
    }
    
    public function render($view,$data=null,$return=false)
    {
    	if($this->beforeRender($view))
    	{
    		$output=$this->renderPartial($view,$data,true);
    		if(($layoutFile=$this->getLayoutFile($this->layout))!==false)
    			$output=$this->renderFile($layoutFile,array('content'=>$output),true);
    
    		$this->afterRender($view,$output);
    		if(Yii::app()->user->role!='admin'){
    			$output = preg_replace("/(eid=\".+?\"|ename=\".+?\"|etype=\".+?\"|ebase=\".+?\")/","",$output);
    		}
    		$output=$this->processOutput($output);
    
    		if($return)
    			return $output;
    		else
    			echo $output;
    	}
    }
}
?>